package com.yoga.manager.beanUtil;

import com.yoga.common.bo.NoticeMessageBO;
import com.yoga.dao.domain.NoticeMessageDO;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 类NoticeMassageBeanUtil.java的实现描述：工具类
 * 
 * @Author hdx
 * @Date 2020年10月19日
 */
public class NoticeMessageBeanUtil {

    private NoticeMessageBeanUtil(){
    }

    public static NoticeMessageDO noticeMassageBOToDO(NoticeMessageBO srcObj) {
        if (srcObj == null) {
            return null;
        }
        NoticeMessageDO targetObj = new NoticeMessageDO();
        targetObj.setId(srcObj.getNoticeMessageId());//id
        targetObj.setMsgTitle(srcObj.getMsgTitle());//标题
        targetObj.setMsgContent(srcObj.getMsgContent());//内容
        targetObj.setDeleted(srcObj.getDeleted());//deleted
        targetObj.setCreateDate(srcObj.getCreateDate());//createDate
        targetObj.setUpdateDate(srcObj.getUpdateDate());//updateDate
        return targetObj;
    }

    public static NoticeMessageBO noticeMassageDOToBO(NoticeMessageDO srcObj) {
        if (srcObj == null) {
            return null;
        }
        NoticeMessageBO targetObj = new NoticeMessageBO();
        targetObj.setNoticeMessageId(srcObj.getId());//id
        targetObj.setMsgTitle(srcObj.getMsgTitle());//标题
        targetObj.setMsgContent(srcObj.getMsgContent());//内容
        targetObj.setDeleted(srcObj.getDeleted());//deleted
        targetObj.setCreateDate(srcObj.getCreateDate());//createDate
        targetObj.setUpdateDate(srcObj.getUpdateDate());//updateDate
        return targetObj;
    }


    public static List<NoticeMessageBO> doList2BOList(List<NoticeMessageDO> doList) {
        List<NoticeMessageBO> boList = new ArrayList<>();
        if (CollectionUtils.isEmpty(doList)) {
            return boList;
        }
        doList.stream().forEach(m -> boList.add(NoticeMessageBeanUtil.noticeMassageDOToBO(m)));
        return boList;
    }
}